/*
 * Copyright (c) 2020, 2019 Girish M
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA 02110-1301, USA.
 * 
 */
let createKeyTest = () => {
    var http = require("http");

    var options = {
        "method": "POST",
        "hostname": "localhost",
        "port": "3000",
        "path": [
            "cache"
        ],
        "headers": {
            "Content-Type": "application/json",
            "User-Agent": "PostmanRuntime/7.20.1",
            "Accept": "*/*",
            "Cache-Control": "no-cache",
            "Postman-Token": "0169a7cd-ebc2-457c-8f3a-4bd203b649a1,0d43ecdd-8ebc-474f-b53a-fd9a4212cfbc",
            "Host": "localhost:3000",
            "Accept-Encoding": "gzip, deflate",
            "Content-Length": "20",
            "Connection": "keep-alive",
            "cache-control": "no-cache"
        }
    };

    var req = http.request(options, function (res) {
        var chunks = [];

        res.on("data", function (chunk) {
            chunks.push(chunk);
        });

        res.on("end", function () {
            var body = Buffer.concat(chunks);
            console.log(body.toString());
        });
    });

    req.write(JSON.stringify({ key: 'aft223' }));
    req.end();
};

let getAllKeysTest = () => {
    var http = require("http");

    var options = {
        "method": "GET",
        "hostname": "localhost",
        "port": "3000",
        "path": [
            "cache"
        ],
        "headers": {
            "User-Agent": "PostmanRuntime/7.20.1",
            "Accept": "*/*",
            "Cache-Control": "no-cache",
            "Postman-Token": "32a09eac-ea40-4622-bda8-8960ff5166cc,c9bbb80e-d512-45fd-89db-a5c1a7654bc9",
            "Host": "localhost:3000",
            "Accept-Encoding": "gzip, deflate",
            "Connection": "keep-alive",
            "cache-control": "no-cache"
        }
    };

    var req = http.request(options, function (res) {
        var chunks = [];

        res.on("data", function (chunk) {
            chunks.push(chunk);
        });

        res.on("end", function () {
            var body = Buffer.concat(chunks);
            console.log(body.toString());
        });
    });

    req.end();
}

createKeyTest();
getAllKeysTest();
